{
  Copyright 2012, Jameel Halabi

  This unit is part of the BlaiseWave wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}

unit BW_Host;

{$mode objfpc}{$H+}

interface

uses
  BW_Global,

  LW_Host  ;

type
  { TMessage }

  TMessage = class(TGlobal)
  protected
    function  GetGlobalType                  : String; override;
  public
    procedure Info
              (const Line1    : PChar      ;
               const Line2    : PChar = nil) ;
    procedure Error
              (const Line1    : PChar      ;
               const Line2    : PChar = nil) ;
    procedure Warning
              (const Line1    : PChar      ;
               const Line2    : PChar = nil) ;
    function  OkCancel
              (const Title    : PChar      ;
               const Line1    : PChar      ;
               const Line2    : PChar = nil) : Integer;
    function  YesNo
              (const Title    : PChar      ;
               const Line1    : PChar      ;
               const Line2    : PChar = nil) : Integer;
    function  YesNoCan
              (const Title    : PChar      ;
               const Line1    : PChar      ;
               const Line2    : PChar = nil) : integer;
    function  YesNoAll
              (const Title    : PChar      ;
               const Line1    : PChar      ;
               const Line2    : PChar = nil) : Integer;
    function  AskName
              (const Title    : PChar      ;
               const ALabel   : PChar      ;
               const InitName : PChar = nil) : PChar  ;
  end;

  { TCommand }

  TCommand = class(TGlobal)
  protected
    function  GetGlobalType  : String ; override;

  public
    function  Evaluate
              (Cmd : String) : Integer;
  end;

implementation

{ TCommand }

function  TCommand.GetGlobalType  : String ;
begin
  Result := LWCOMMANDFUNC_GLOBAL;
end;

function  TCommand.Evaluate
                   (Cmd : String) : Integer;
begin
  Result := TLWCommandFunc(FGlobal)(PChar(Cmd));
end;

{ TMessage }

function  TMessage.GetGlobalType            : String;
begin
  Result := LWMESSAGEFUNCS_GLOBAL;
end;

procedure TMessage.Info
                   (const Line1    : PChar;
                    const Line2    : PChar) ;
begin
  PLWMessageFuncs(FGlobal)^.Info(Line1, Line2);
end;

procedure TMessage.Error
                   (const Line1    : PChar;
                    const Line2    : PChar) ;
begin
  PLWMessageFuncs(FGlobal)^.Error(Line1, Line2);
end;

procedure TMessage.Warning
                   (const Line1    : PChar;
                    const Line2    : PChar) ;
begin
  PLWMessageFuncs(FGlobal)^.Warning(Line1, Line2);
end;

function  TMessage.OkCancel
                   (const Title    : PChar;
                    const Line1    : PChar;
                    const Line2    : PChar) : Integer;
begin
  Result := PLWMessageFuncs(FGlobal)^.OkCancel(Title, Line1, Line2);
end;

function  TMessage.YesNo
                   (const Title    : PChar;
                    const Line1    : PChar;
                    const Line2    : PChar) : Integer;
begin
  Result := PLWMessageFuncs(FGlobal)^.YesNo(Title, Line1, Line2);
end;

function  TMessage.YesNoCan
                   (const Title    : PChar;
                    const Line1    : PChar;
                    const Line2    : PChar) : Integer;
begin
  Result := PLWMessageFuncs(FGlobal)^.YesNoCan(Title, Line1, Line2);
end;

function  TMessage.YesNoAll
                   (const Title    : PChar;
                    const Line1    : PChar;
                    const Line2    : PChar) : Integer;
begin
  Result := PLWMessageFuncs(FGlobal)^.YesNoAll(Title, Line1, Line2);
end;

function  TMessage.AskName
                   (const Title    : PChar;
                    const ALabel   : PChar;
                    const InitName : PChar) : PChar  ;
begin
  Result := PLWMessageFuncs(FGlobal)^.AskName(Title, ALabel, InitName);
end;

end.

